import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/cmdb`

export function getCmdbServiceList(params) {
  return request.get(`${AUTH_PREFIX_V1}/services`, { params }).then(res => camelCaseObject(res))
}

export function getCmdbServiceListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/services/page`, { params }).then(res => camelCaseObject(res))
}

export function getCmdbService(serviceId) {
  return request.get(`${AUTH_PREFIX_V1}/services/${serviceId}`).then(res => camelCaseObject(res))
}

export function createCmdbService(params) {
  return request.post(`${AUTH_PREFIX_V1}/services`, params).then(res => camelCaseObject(res))
}

export function updateCmdbService(serviceId, params) {
  return request.put(`${AUTH_PREFIX_V1}/services/${serviceId}`, params).then(res => camelCaseObject(res))
}

export function deleteCmdbService(serviceId) {
  return request.delete(`${AUTH_PREFIX_V1}/services/${serviceId}`).then(res => camelCaseObject(res))
}

export function bulkAddServiceAsset(serviceId, params) {
  return request.put(`${AUTH_PREFIX_V1}/services/${serviceId}/assets/bulk_add`, params).then(res => camelCaseObject(res))
}

export function bulkDeleteServiceAsset(serviceId, params) {
  return request.put(`${AUTH_PREFIX_V1}/services/${serviceId}/assets/bulk_delete`, params).then(res => camelCaseObject(res))
}
